import SDKManager from "../../../sdk/SDKManager";
import GameItemModel from "../../../sdk/base/GameItemModel";
import RandomHelper from "../../../cfw/tools/RandomHelper";

// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

const { ccclass, property } = cc._decorator;

@ccclass
export default class AutoJumpView extends cc.Component {


    @property
    zs_random_jump: boolean = true;


    start() {
        if (this.zs_random_jump) {
            if (SDKManager.getChannel().getRandom_jump()) {
                this.jump()
            }
        } else {
            this.jump()
        }

    }

    jump() {
        let auto = SDKManager.getChannel().getAuto_jump_switch()
        if (auto == 1) {
            let list = SDKManager.getChannel().getAdData();
            if (list) {
                let model: GameItemModel = list[RandomHelper.random(0, list.length)]
                if (model) {
                    SDKManager.getChannel().navigate2Mini(model)
                }

            }
        }
    }

    // update (dt) {}
}
